package cn.gson.crmdemo.model.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crmdemo.model.dao.InvoiceDao;
import cn.gson.crmdemo.model.mapper.InvoiceMapper;
import cn.gson.crmdemo.model.pojo.Customer;
import cn.gson.crmdemo.model.pojo.Getmoneyplan;
import cn.gson.crmdemo.model.pojo.Invoice;
import cn.gson.crmdemo.model.vo.FpVo;

@Service
@Transactional(rollbackFor=Exception.class)
public class InvoiceService {
	@Autowired
	InvoiceMapper im;
	@Autowired
	InvoiceDao ia;
	//查询发票
	public JSONArray selectfp(String invoiceDate,String invoiceNo,Integer invoiceSfhk){
		return im.selectfp(invoiceDate,invoiceNo,invoiceSfhk);
	}
	/*
	 * 添加发票记录
	 */
	public void addfp(FpVo fo) {
		Invoice ie=new Invoice();
		ie.setInvoiceDate(fo.getInvoiceDate());
		ie.setInvoiceEmpName(fo.getInvoiceEmpName());
		ie.setInvoiceMoney(fo.getInvoiceMoney());
		ie.setInvoiceNo(fo.getInvoiceNo());
		ie.setInvoiceNotice(fo.getInvoiceNotice());
		ie.setInvoiceSfhk(fo.getInvoiceSfhk());
		Customer cr=new Customer();
		cr.setCustomerId(fo.getContractId());
		ie.setCustomer(cr);
		ie.setoId(fo.getoId());
		ia.save(ie);
	}
	/*
	 * 日期查询
	 */
	public JSONArray selectsj(String rq) {
		return im.selectsj(rq);
		
	}
	/*
	 * 发票号查询
	 */
	public JSONArray selectfph(String fph) {
		return im.selectfph(fph);
		
	}
	//付款方式查询
	public JSONArray selectfs(Integer t) {
		return im.selectfs(t);
	}
	
}
